package com.szmg.wishwalls.action;

import java.util.Collections;
import java.util.List;

import javax.annotation.Resource;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.szmg.wishwalls.model.Menu;
import com.szmg.wishwalls.service.MenuService;

@Controller("menuAction")
public class MenuAction {
	private static final Logger log = LoggerFactory.getLogger(MenuAction.class);
	@Resource(name="menuService")
	private MenuService menuService;
	
	@RequestMapping(value="/json/wishwall/menu_queryProgramBaseMenu",method=RequestMethod.GET)
    @ResponseBody
	public List<Menu> queryProgramBaseMenu(String programCode){
		List<Menu> menuList = Collections.emptyList();
		try{
			menuList = menuService.queryProgramBaseMenu(programCode);
		}catch(Exception e){
			log.error("MenuAction queryProgramBaseMenu error!",e);
		}
		return menuList;
	}
	
	@RequestMapping(value="/json/wishwall/menu_queryMenuByParentId",method=RequestMethod.GET)
    @ResponseBody
	public List<Menu> queryMenuByParentId(String programCode,String parentId){
		List<Menu> menuList = Collections.emptyList();
		try{
			menuList = menuService.queryMenuByParentId(programCode,parentId);
		}catch(Exception e){
			log.error("MenuAction queryMenuByParentId error!",e);
		}
		return menuList;
	}
}
